<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>模版字符串</title>
  <script type="text/javascript">

    //用  ``  而不是""或''

    //1.
    //用``，使用原生的字符串，
    // 换行的话，输出结果也会换行
    let str1=`for(int i=0;i<19;I++){
        System.out.println("i= ",i)}`;


    //2.字符串插入变量或表达式
    let name="gz"
    //注意是``
    let str2=`名字${name}`  //就近原则，找到最近的name
    console.log(str2)

    let str3=`1+2=${1+2}`
    console.log(str3)

    //3.字符串中调用函数
    function sayHi(name){
      return "hi"+name;
    }
    let name2="tom"
    let str4=`sayHi()返回的结果是${sayHi("jack")}`; //hijack
    let str5=`sayHi()返回的结果是${name2}`;  //tom
    console.log(str4)
    console.log(str5)

  </script>
</head>
<body>

</body>
</html>